﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using TouchRC.Classes;
using Microsoft.Drawing;
using System.Drawing;
using TouchRC.Logic;
using TouchRC.MetadataCaching;
using System.Windows.Forms;

namespace TouchRC.Custom_Controls
{
    public class MenuButton : TouchButton
    {
        #region Private Members

        private MenuItemOption m_MenuItemOption;

        #endregion

        public MenuButton(MenuItemOption option)
            :base()
        {
            m_MenuItemOption = option;
        }

        public override bool OnClick(PointEventArgs e)
        {
            bool handled = false;
            if (m_MenuItemOption == MenuItemOption.DVD)
            {
                VmcControllerRemote remote = new VmcControllerRemote(MainMenuPanel.CurrentComputer);
                remote.PressButton(RemoteCommands.ButtonCommands.Dvdmenu);
                handled = true;
            }
            else if (m_MenuItemOption == MenuItemOption.MusicLibrary)
            {
            }
            else if (m_MenuItemOption == MenuItemOption.MusicQueue)
            {
            }
            else if (m_MenuItemOption == MenuItemOption.NowPlaying)
            {
                NowPlayingPanel panel = new NowPlayingPanel();//.Instance.ShowNowPlaying();
                panel.ShowNowPlaying();
                handled = true;
            }
            else if (m_MenuItemOption == MenuItemOption.TvGuide)
            {
            }
            else if (m_MenuItemOption == MenuItemOption.TvLive)
            {
                VmcControllerRemote remote = new VmcControllerRemote(MainMenuPanel.CurrentComputer);
                remote.GoToScreen(RemoteCommands.GoToPlaces.LiveTV);
                handled = true;
            }
            else if (m_MenuItemOption == MenuItemOption.TvRecorded)
            {
                
            }
            else if (m_MenuItemOption == MenuItemOption.VideoLibrary)
            {
                Cursor.Current = Cursors.WaitCursor;
                MetadataCollection collection = MainMenuPanel.CurrentComputer.MetadataCollection;
                Cursor.Current = Cursors.Default;
                if (collection.Count > 0)
                {
                    MediaBrowserPanel panel = new MediaBrowserPanel(collection);
                    panel.ShowMaximized();
                }
                else
                {
                    MessageDialog.Show(string.Format("No media found in {0}", MainMenuPanel.CurrentComputer.MetadataCacheDir), "Ok", null);
                }
                handled = true;
            }
            else if (m_MenuItemOption == MenuItemOption.PictureLibrary)
            {
            }
            else
            {
            }

            if (!handled)
            {
                MessageDialog.Show(string.Format("Not Implemented {0} Yet", m_MenuItemOption), "Ok", null);
            }
            return false;
        }
    }
}
